package com.GlobalPaint.app.ui.HTML.adpter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.GlobalPaint.app.R;
import com.GlobalPaint.app.bean.PaletteDetailsBean;
import com.GlobalPaint.app.utils.Constants;
import com.squareup.picasso.Picasso;

/**
 * Created by Administrator on 2018/1/3 0003.
 */

public class tujiAdpter extends RecyclerView.Adapter<tujiAdpter.ViewHolder>{
    private PaletteDetailsBean.DataBean.FImageBean Bean;
    private Context context;
    public tujiAdpter(PaletteDetailsBean.DataBean.FImageBean bean, Context context) {
        this.Bean=bean;
        this.context=context;
    }

    @Override
    public tujiAdpter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.tujie_listview_item, parent, false);
        tujiAdpter.ViewHolder holder = new tujiAdpter.ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(tujiAdpter.ViewHolder holder, int position) {
        String url= Constants.JASON_SERVICE_URL+"/QlwCms"+Bean.getFImage()==
                null?"http://218.192.170.132/1.jpg":Constants.JASON_SERVICE_URL+"/QlwCms"+Bean.getFImage();
        Picasso.with(context).load(url)
                .into(holder.img);

        String bt=Bean.getFText()==
                null?"":Bean.getFText();
        holder.tv_jianjie.setText(bt);
    }

    @Override
    public int getItemCount() {

        return 1;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private final ImageView img;
        private final TextView tv_jianjie;

        public ViewHolder(View itemView) {
            super(itemView);
            img = (ImageView)itemView. findViewById(R.id.img);
            tv_jianjie = (TextView)itemView. findViewById(R.id.tv_jianjie);
        }
    }
}
